<?php 
	$health_fund_id = 0;

	//for form submit
	if($_SERVER['REQUEST_METHOD'] == "POST"){
		if(isset($_POST['id']) && !empty($_POST['id'])){
			$table_def 	= array(
							'update' => $_POST,
							'filter' => 'id = '.$_POST['id']
						  );
			$fund 		= new HealthFund($table_def);
			$fund->Update();
			$message = 2;
		}else{
			$_POST['date_created'] = date("Y-m-d h:i:s");
			$table_def 	= array('add' => $_POST);
			$fund 		= new HealthFund($table_def);
			$fund->Insert();
			$message = 1;
		}
	}

	//for edit form - fetch data
	if($_SERVER['REQUEST_METHOD'] == "GET"){
		$message = 0;
		if(isset($_GET['id']) && !empty($_GET['id'])){
			$health_fund_id = $_GET['id'];

			$params = array( 'filter' => 'id = '.$health_fund_id);
			$fund 	= new HealthFund($params);
			$row 	= $fund->Select();
		}
	}
?>